package com.zone.gateway.core.bind;

import com.zone.gateway.core.session.GatewaySession;
import com.zone.gateway.core.mapping.HttpStatement;
import com.zone.gateway.core.session.Configuration;

import java.lang.reflect.Method;
import java.util.Map;

/**
 * @author: zongzi
 * @description: 泛化调用执行引擎，根据不同的http type执行各种分支
 * @date: 2025/4/18
 */
public class MappedMethod {
    private final String uri;
    private final GatewaySession gatewaySession;

    public MappedMethod(String uri, GatewaySession gatewaySession) {
        this.uri = uri;
        this.gatewaySession = gatewaySession;
    }

    /**
     * 调用执行器方法
     *
     * @param method
     * @param args
     * @return
     */
    public Object execute(Method method, Map<String, Object> args) {
        Configuration configuration = gatewaySession.getConfiguration();
        HttpStatement httpStatement = configuration.getHttpStatement(uri);
        switch (httpStatement.getType()) {
            case GET:
                return gatewaySession.get(method, args);
            case POST:
                break;
            case PUT:
                break;
            case DELETE:
                break;
            case UN_KNOW:
                break;
            default:
                return null;
        }
        return null;
    }
}
